package com.zhongfl.crm.enums.boss;

import lombok.Getter;

/**
 * 工单类型
 * Created by wangkun23 on 2018/5/4.
 */
public enum WorkOrderTypeCode {

    /**
     * 工单类型
     */
    VALUATION("20000", "评估服务", "评估库"),
    COMPANY_WRAP("30000", "公司服务", "司服库"),
    INTERVIEW("40000", "签约公证", "签约库"),
    INFORMATION("10000", "资料采集", "采集库"),
    ROLLS("50000", "报卷", "申报库"),
    LOAN_APPROVE("60000", "审批", "审批库"),
    ROOM("65000", "取房本", "批贷库"),
    WARRANT("70000", "进抵", "进抵库"),
    MORTGAGES("110000", "他证", "进抵库"),
    LOANED("80000", "放款", "放款库"),
    LOAN_FEE("90000", "收服务费", "入账库"), // 这个工单干掉,先不要了。
    LIQUIDATION("100000", "入账清算", "清结算库"),
    OTHER("0", "默认", "");

    @Getter
    private String key;
    @Getter
    private String value;

    @Getter
    private String storeName;

    public static WorkOrderTypeCode convert(OrderStatus orderStatus) {
        switch (orderStatus) {
            case STATUS_CREATED:
                return WorkOrderTypeCode.OTHER;
            case STATUS_COLLECT:
                return WorkOrderTypeCode.INFORMATION;
            case STATUS_DECLARE:
                return WorkOrderTypeCode.ROLLS;
            case STATUS_APPROVAL:
                return WorkOrderTypeCode.LOAN_APPROVE;
            case STATUS_PIDAI:
                return WorkOrderTypeCode.ROOM;
            case STATUS_STORAGE:
                return WorkOrderTypeCode.MORTGAGES;
            case STATUS_APPLICAT:
                return WorkOrderTypeCode.LOANED;
            case STATUS_ACCOUNT:
                return WorkOrderTypeCode.LIQUIDATION;
            case STATUS_COMPLETED:
                return WorkOrderTypeCode.OTHER;
            case STATUS_CANCEL:
                return WorkOrderTypeCode.OTHER;
            default:
                return WorkOrderTypeCode.OTHER;
        }
    }

    public static WorkOrderTypeCode getNextTypeCode(WorkOrderTypeCode currentTypeCode) {
        switch (currentTypeCode) {
            case VALUATION:
                return WorkOrderTypeCode.OTHER;
            case COMPANY_WRAP:
                return WorkOrderTypeCode.OTHER;
            case INTERVIEW:
                return WorkOrderTypeCode.OTHER;
            case INFORMATION:
                return WorkOrderTypeCode.ROLLS;
            case ROLLS:
                return WorkOrderTypeCode.LOAN_APPROVE;
            case LOAN_APPROVE:
                return WorkOrderTypeCode.ROOM;
            case ROOM:
                return WorkOrderTypeCode.WARRANT;
            case WARRANT:
                return WorkOrderTypeCode.MORTGAGES;
            case MORTGAGES:
                return WorkOrderTypeCode.LOANED;
            case LOANED:
                return WorkOrderTypeCode.LOAN_FEE;
            case LOAN_FEE:
                return WorkOrderTypeCode.LIQUIDATION;
            case LIQUIDATION:
                return WorkOrderTypeCode.OTHER;
            case OTHER:
                return WorkOrderTypeCode.OTHER;
            default:
                return WorkOrderTypeCode.OTHER;

        }
    }

    WorkOrderTypeCode(String key, String value, String storeName) {
        this.key = key;
        this.value = value;
        this.storeName = storeName;
    }

    public static WorkOrderTypeCode getEnumByName(String name) {
        for (WorkOrderTypeCode item : WorkOrderTypeCode.values()) {
            if (item.name().equals(name)) {
                return item;
            }
        }
        return OTHER;
    }

}
